package com.ysd.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ysd.dao.impl.ChanPinSoSuoDaoImpl;
import com.ysd.entity.Product;

public class ChanPinSoSuoServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html");
		HttpSession session = request.getSession();

		String sosuo = request.getParameter("sosuo");
		session.setAttribute("sosuo", sosuo);
		ChanPinSoSuoDaoImpl cpssDao = new ChanPinSoSuoDaoImpl();
		ArrayList<Product> chanpinxiangqingsosuo = cpssDao.getChanPinSuoSou(sosuo);
		request.setAttribute("cpxqss", chanpinxiangqingsosuo);
		session.setAttribute("cpxqss", chanpinxiangqingsosuo);
		request.getRequestDispatcher("NewFile.jsp").forward(request, response); // 转发
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
